<template>
  <div class="bgc-default">
    <div class="top-nav">
      <template v-for="(item, key) of topNavBar">
        <div :key="key" class="nav-item" v-if="item.showFlag" :class="{'nav-active' : selectedNavKey === key}"
          @click="goTarget(key)">{{item.name}}</div>
      </template>
    </div>

    <div class="bg-color-white pad-20 mar-20">
      <!-- 账期设置 -->
      <div class="scroll-item" id="account-set" v-if="topNavBar['account-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">账期及佣金</div>
        </div>
        <div class="config-item">
          <h5>佣金设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">比例佣金计算模式</label>
              <el-select v-model="enterpriseConfig.commissionCalculationType" placeholder="请选择" style="width: 250px;">
                <el-option label="按商品销售金额计算" value='1'></el-option>
                <el-option label="按商品毛利计算" value='2'></el-option>
              </el-select>
            </div>
            <div class="config-tip font-12 font-color-9">
              设置店主佣金、顾客分销佣金按比例计算时的模式，选择“按商品毛利计算”时，按（零售价-供应价）×佣金比例计算，</div>
            <div class="config-tip font-12 font-red">当订单因使用优惠或参与活动导致毛利不足以扣减相关佣金时，将从商品成本中继续扣除不足部分。</div>
          </div>
        </div>
        <div class="config-item">
          <h5>账期设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动确认发货</label>
              <label class="config-label-2 mar-r-15">订单发货后</label>
              <el-input v-model="enterpriseConfig.updateOrderReceived" style="width: 250px;" maxlength="3"
                @keyup.native="enterpriseConfig.updateOrderReceived = checkInputPositiveNum(enterpriseConfig.updateOrderReceived)">
                <template slot="append">天</template>
              </el-input>
            </div>
            <div class="config-tip-2 font-12 font-color-9">设置订单发货之后几天自动变为已收货状态，最短为1天。</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">订单完成时间</label>
              <label class="config-label-2 mar-r-15">订单收货后</label>
              <el-input v-model="enterpriseConfig.updateOrderCompleted" style="width: 250px;" maxlength="3"
                @keyup.native="enterpriseConfig.updateOrderCompleted = checkInputNum(enterpriseConfig.updateOrderCompleted)">
                <template slot="append">天</template>
              </el-input>
            </div>
            <div class="config-tip-2 font-12 font-color-9">设置订单收货之后几天变为完成状态。</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">订单失效时间</label>
              <label class="config-label-2 mar-r-15">订单未付款后</label>
              <el-input v-model="enterpriseConfig.updateOrderInvalid" style="width: 250px;" maxlength="10"
                @keyup.native="enterpriseConfig.updateOrderInvalid = checkInputPositiveNum(enterpriseConfig.updateOrderInvalid)">
                <template slot="append">分钟</template>
              </el-input>
            </div>
            <div class="config-tip-2 font-12 font-color-9">设置待付款待订单自动失效时间，默认为24小时。</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">售后设置</label>
              <el-checkbox v-model="enterpriseAudit" @change="changeEnterpriseAudit">总部审核售后单</el-checkbox>
            </div>
            <div class="config-tip font-12 font-color-9">开启之后,售后单转由总部审核,发货端不再审核流程状态</div>
            <div class="v-align-c">
              <label class="config-label mar-r-15"></label>
              <el-checkbox v-model="enableAfterSaleWarehouse" @change="changeEnableAfterSaleWarehouse"
                :disabled="enableAfterSaleWarehouseCheckbox">启用售后仓</el-checkbox>
              <label class="config-label-2 mar-r-15">默认售后仓</label>
              <el-select v-model="enterpriseConfig.defaultAfterSaleWarehouseId"
                @change="changeDefaultAfterSaleWarehouse" :disabled="!enableAfterSaleWarehouse">
                <el-option v-for="item in afterSaleWarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                  :value="item.warehouseId"></el-option>
              </el-select>
            </div>
            <div class="config-tip font-12 font-color-9">不勾选时所有商品按发货仓原路退回。</div>
          </div>
        </div>
      </div>
      <!-- 商品设置 -->
      <div class="scroll-item" id="goods-set" v-if="topNavBar['goods-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">商品设置</div>
        </div>
        <div class="config-item">
          <h5>商品分类</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">零售与批发商品分类分开设置</label>
              <el-radio-group v-model="enterpriseConfig.categorySeparate">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，批发商品分类可与零售商品分类不同，否则共用零售商品分类</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">批发商品分类使用别名</label>
              <el-radio-group v-model="enterpriseConfig.wholesaleCategoryAlias">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，批发商品分类名称按商品分类的别名显示</div>
          </div>
        </div>
      </div>
      <!-- 进销存设置 -->
      <div class="scroll-item" id="warehouse-set" v-if="topNavBar['warehouse-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">进销存设置</div>
        </div>
        <div class="config-item" v-if="enterpriseConfig.warehouseAuthority == 1">
          <h5>税额设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">默认进项税税目</label>
              <el-select v-model="enterpriseConfig.taxItemsId">
                <el-option value="0" label="无"></el-option>
                <el-option v-for="item in taxList" :key="item.taxItemsId" :value="item.taxItemsId"
                  :label="item.taxName"></el-option>
              </el-select>
            </div>
          </div>
          <h5>分仓规则</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15" style="width: 160px;">&nbsp;</label>
              <el-checkbox v-model="warehouseDeliverChecked">启用仓库发货（启用仓库后发货后，商品库存将切换为仓库数量，并将订单分至仓库发货）
              </el-checkbox>
            </div>
            <div class="mar-t-40">
              <div class="v-align-c">
                <label class="config-label mar-r-15" style="width: 160px;">&nbsp;</label>
                <el-checkbox v-model="ignoreAreaChecked">分仓时忽略就近原则（多个仓库可满足整单原则时，直接按仓库顺序号确定发货仓库）
                </el-checkbox>
              </div>
            </div>
          </div>
          <h5>出入库规则</h5>
          <div class="v-align-c">
            <label class="config-label mar-r-15" style="width: 160px;">&nbsp;</label>
            <el-checkbox v-model="warehouseAuditChecked">关闭出入库审核流程（关闭后，出入库单提交后无需经过审核，直接变成已完成状态）
            </el-checkbox>
          </div>
        </div>
      </div>
      <!-- 合伙人设置 -->
      <div class="scroll-item" id="partner-set" v-if="topNavBar['partner-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">合伙人设置</div>
        </div>
        <div class="config-item" v-if="enterpriseConfig.partnerAuthority == 1">
          <h5>提成设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">提成规则</label>
              <el-radio-group v-model="enterpriseConfig.patternCommissionType">
                <el-radio v-for="(val, key) in dict.patternCommissionType" :key="key" :label="key">
                  {{val}}
                </el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">选择一级、二级合伙人的提成比例从商品资料读取，或从合伙人基本资料读取</div>
          </div>
        </div>
        <div class="config-item">
          <h5>自定义信息</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">登录LOGO</label>
              <el-upload list-type="picture-card" action="/api/common/uploadFiles"
                accept="image/jpeg, image/gif, image/png, image/bmp" name="files" :data="token" :show-file-list="false"
                v-loading="fileLoading" :on-success="handleUploadImageUrlSuccess" :before-upload="beforeImageUrlUpload">
                <img v-if="enterpriseConfig.logoUrl" :src="enterpriseConfig.logoUrl"
                  style="width: 150px;height: 50px" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </div>
            <div class="config-tip font-12 font-color-9">设置后在移动端登录页LOGO将对应变化，若不设置则显示默认的LOGO，建议尺寸339*105
            </div>
          </div>
          <div class="mar-t-40" v-if="enterpriseConfig.partnerAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">一级合伙人别名</label>
              <el-input v-model="enterpriseConfig.levelOnePartnerAliasName" style="width: 250px;"
                placeholder="请输入一级合伙人别名，1-5字" maxlength="5"></el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置在移动端界面上替换“一级合伙人”字样的别名。</div>
          </div>
          <div class="mar-t-40" v-if="enterpriseConfig.partnerAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">二级合伙人别名</label>
              <el-input v-model="enterpriseConfig.levelTwoPartnerAliasName" style="width: 250px;"
                placeholder="请输入二级合伙人别名，1-5字" maxlength="5"></el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置在移动端界面上替换“二级合伙人”字样的别名。</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">默认审核</label>
              <el-switch v-model="partnerDefaultExamineFlag" active-color="#13ce66"></el-switch>
            </div>
            <div class="config-tip font-12 font-color-9">开启后二级合伙人申请时,系统将默认审核通过</div>
          </div>
        </div>
      </div>
      <!-- 招募员设置 -->
      <div class="scroll-item" id="recruiter-set" v-if="topNavBar['recruiter-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">招募员设置</div>
        </div>
        <div class="config-item">
          <h5>提成设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">提成规则</label>
              <el-radio-group v-model="enterpriseConfig.recruiterCommissionType">
                <el-radio v-for="(val, key) in dict.recruiterCommissionType" :key="key" :label="key">
                  {{val}}
                </el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">选择招募员的提成比例从商品资料读取，或从招募员基本资料读取</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">默认分销比例</label>
              <el-input class="width-250" v-model="enterpriseConfig.recruiterDistributeRatio" placeholder="请输入分销比例"
                @blur="enterpriseConfig.recruiterDistributeRatio = checkNum(enterpriseConfig.recruiterDistributeRatio)">
                <template slot="append">%</template>
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置保存后所有新增的招募员自动读取该分销比例</div>
          </div>
        </div>
        <div class="config-item">
          <h5>自定义信息</h5>
          <div class="mar-t-40" v-if="enterpriseConfig.partnerAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">招募员别名</label>
              <el-input v-model="enterpriseConfig.recruiterAliasName" style="width: 250px;" placeholder="请输入招募员别名，1-5字"
                maxlength="5"></el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置后在合伙人系统和招募员系统中将替换"招募员"字样的别名</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">默认审核</label>
              <el-switch v-model="recruiterDefaultExamineFlag" active-color="#13ce66"></el-switch>
            </div>
            <div class="config-tip font-12 font-color-9">开启后招募员申请时,系统将默认审核通过</div>
          </div>
        </div>
      </div>
      <!-- 主播设置 -->
      <div class="scroll-item" id="anchor-set" v-if="topNavBar['anchor-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">主播设置</div>
        </div>
        <div class="config-item">
          <!-- <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">结算规则</label>
              <el-radio-group v-model="enterpriseConfig.settlementRuleAuth">
                <el-radio label="0">按商品提成比例</el-radio>
                <el-radio label="1">按主播提成比例</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">
              <div>选择招募员的提成比例从商品资料读取，或从招募员基本资料读取</div>
              <div>按主播提成比例：根据主播每场直播间的合计成交订单金额按主播提成比例结算</div>
            </div>
          </div> -->
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">强制完善主体认证</label>
              <el-radio-group v-model="enterpriseConfig.isOpenAnchorCompulsoryPerfectionInfo">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，用户在选品小程序中申请主播时必须先完善主体才能申请主播权限</div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动审核主播</label>
              <el-radio-group v-model="enterpriseConfig.anchorAutoApprove">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">一级合伙人佣金详情</label>
              <el-radio-group v-model="enterpriseConfig.isShowAnchorOnePartnerCommission">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">一级合伙人别名</label>
              <el-input v-model="enterpriseConfig.anchorLevelOnePartnerAliasName" style="width: 250px;"
                placeholder="请输入一级合伙人别名，1-10字" maxlength="10"></el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置后，在主播选品小程序选择身份的登录页一级合伙人名称将对应变化。</div>
          </div>
        </div>
      </div>
      <!-- 云店小程序设置 -->
      <div class="scroll-item" id="cloudshop-set" v-if="topNavBar['cloudshop-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">云店小程序设置</div>
        </div>
        <!-- 该企业在运营总后台有开启【社区团购】或【门店到家】增值功能时，才显示且功能逻辑才有效 -->
        <div class="config-item" v-if="(enterpriseConfig.groupBuyAuthority != null && enterpriseConfig.groupBuyAuthority == 1)
				|| (enterpriseConfig.storeHomeAuthority != null && enterpriseConfig.storeHomeAuthority == 1) ">
          <h5>配送设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">默认配送设置</label>
              <el-input v-model="enterpriseConfig.defaultDeliveryRange" style="width: 150px;" maxlength="5"
                @keyup.native="enterpriseConfig.defaultDeliveryRange = checkInputNum(enterpriseConfig.defaultDeliveryRange)">
                <template slot="append">公里</template>
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">例如：设置5公里后门店和社区团长的默认服务范围为提货点5公里范围内，顾客出现在该范围内时才可正常下单。
              若门店和社区团长设置了自定义服务范围，则服务范围为自定义的。</div>
          </div>

        </div>
        <div v-if="enterpriseConfig.memberPriceAuthority == 1" class="config-item">
          <h5>会员设置</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">会员名称</label>
              <el-input v-model="enterpriseConfig.memberTitle" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后商品详情页的“会员”价名称对应变化</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动成为规则</label>
              <el-radio-group>
                <el-radio>满足选中的全部条件</el-radio>
              </el-radio-group>
            </div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动成为条件</label>
              <el-select clearable v-model="enterpriseConfig.autoMemberAttrId" placeholder="请选择自定义表单字段"
                style="width: 250px;" @change="changeAttribute">
                <el-option v-for="attr in attributeList" :key="attr.attributeId" :label="attr.attributeName"
                  :value="attr.attributeId"></el-option>
              </el-select>
              <div v-if="enterpriseConfig.autoMemberAttrId">
                <el-select v-if="attr.attributeType == 'select'" v-model="enterpriseConfig.autoMemberAttrValue">
                  <el-option v-for="option in optionList" :key="option.optionId" :label="option.optionName"
                    :value="option.optionValue"></el-option>
                </el-select>
                <el-date-picker v-else-if="attr.attributeType == 'date'" value-format="yyyy-MM-dd"
                  v-model="enterpriseConfig.autoMemberAttrValue" style="width: 250px;" type="date">
                </el-date-picker>
                <el-checkbox v-else-if="attr.attributeType == 'checkbox'" true-label="1" false-label="0"
                  v-model="enterpriseConfig.autoMemberAttrValue" style="width: 250px;"></el-checkbox>
                <el-input v-else v-model="enterpriseConfig.autoMemberAttrValue" style="width: 250px;" maxlength="20">
                </el-input>
              </div>
            </div>
          </div>
        </div>
        <div class="config-item">
          <h5>云店申请相关</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动审核云店</label>
              <el-radio-group v-model="enterpriseConfig.isShopAutoApprove">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，云店的开通申请到达云企后台时会自动通过，无需人工处理。</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">Banner图入口</label>
              <el-radio-group v-model="enterpriseConfig.isShopBannerShow">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">隐藏后，云店小程序买家中心将隐藏申请店主入口</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">Banner图</label>
              <el-upload list-type="picture-card" action="/api/common/uploadFiles"
                accept="image/jpeg, image/gif, image/png, image/bmp" name="files" :data="token" :show-file-list="false"
                v-loading="bannerFileLoading" :on-success="handleUploadBannerSuccess"
                :before-upload="beforeBannerUpload">
                <img v-if="enterpriseConfig.shopBannerUrl" :src="enterpriseConfig.shopBannerUrl"
                  style="width: 150px;height: 50px" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </div>
            <div class="config-tip font-12 font-color-9">设置后在云店小程序买家中心申请店主Banner将对应变化，若不设置则显示默认图。建议尺寸690×76
            </div>
          </div>
          <div class="mar-t-40" v-if="enterpriseConfig.partnerAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">申请店主页顶部标题</label>
              <el-input v-model="enterpriseConfig.shopTopTitle" style="width: 250px;" placeholder="请输入标题，最多8个字"
                maxlength="8" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后在申请店主页的小程序顶部标题中将替换自定义的文字。</div>
          </div>
          <div class="mar-t-40" v-if="enterpriseConfig.partnerAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">标题栏背景</label>
              <div class="flex">
                <el-color-picker v-model="enterpriseConfig.shopTopTitleBackground"
                  @active-change="activecolorChange(enterpriseConfig, 'shopTopTitleBackground', '#FFFFFF', $event)"
                  @change="colorChange(enterpriseConfig, 'shopTopTitleBackground', '#FFFFFF', $event)"
                  :predefine="predefineColors" class="color-sel" />
                <el-input class="mar-l-10 color-sel-input" placeholder="请输入内容"
                  v-model="enterpriseConfig.shopTopTitleBackground"
                  @change="iptColorChange(enterpriseConfig, 'shopTopTitleBackground', '#FFFFFF', $event)">
                </el-input>
                <el-button class="color-sel-btn"
                  @click="resetColor(enterpriseConfig, 'shopTopTitleBackground', '#FFFFFF')">重置
                </el-button>
              </div>
            </div>
            <!-- <div class="config-tip font-12 font-color-9">设置后在申请店主页的小程序顶部标题中将替换自定义的文字。</div> -->
          </div>
        </div>
        <!-- groupBuyAuthority -->
        <div class="config-item" v-if="enterpriseConfig.groupBuyAuthority == 1">
          <h5>社区团购相关</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动审核团长</label>
              <el-radio-group v-model="enterpriseConfig.isCommanderAutoApprove">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，申请社区团长后将自动审核通过，无需人工审核</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">Banner图入口</label>
              <el-radio-group v-model="enterpriseConfig.isCommanderBannerShow">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">隐藏后，云店小程序买家中心将隐藏申请团长入口</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">Banner图</label>
              <el-upload list-type="picture-card" action="/api/common/uploadFiles"
                accept="image/jpeg, image/gif, image/png, image/bmp" name="files" :data="token" :show-file-list="false"
                v-loading="bannerFileLoading" :on-success="handleUploadCommanderBannerSuccess"
                :before-upload="beforeBannerUpload">
                <img v-if="enterpriseConfig.commanderBannerUrl" :src="enterpriseConfig.commanderBannerUrl"
                  style="width: 150px;height: 50px" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </div>
            <div class="config-tip font-12 font-color-9">设置后在云店小程序买家中心申请团长Banner将对应变化，若不设置则显示默认图。建议尺寸690×76
            </div>
          </div>
        </div>
        <div class="config-item">
          <h5>直播相关</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">直播回放显示设置</label>
              <el-radio-group v-model="enterpriseConfig.isLivePlaybackType">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">隐藏后，云店的小程序直播列表将不显示直播回放</div>
          </div>
          <div class="mar-t-40"
            v-if="(getVersionType() == 4 || getVersionType() == 5) && enterpriseConfig.liveAuthority == 1">
            <div class="v-align-c">
              <label class="config-label mar-r-15">直播PK榜显示</label>
              <el-radio-group v-model="enterpriseConfig.isLiveShowType">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">隐藏后，云店小程序卖家中心将隐藏直播PK榜入口</div>
          </div>
        </div>
        <div class="config-item"
          v-if="enterpriseConfig.shopCustomerServiceAuthority == 1 && enterpriseConfig.enterpriseCustomerServiceAuthority == 1">
          <h5>客服相关</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">接待客服</label>
              <el-radio-group v-model="enterpriseConfig.customerServiceType">
                <el-radio :label="1">小B客服</el-radio>
                <el-radio :label="2">企业客服</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">选择后顾客点击分销订单的联系客服按钮将进入不同的客服系统</div>
          </div>
        </div>
        <div class="config-item">
          <h5>其它</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">任务海报显示</label>
              <el-radio-group v-model="enterpriseConfig.isTaskPosterAuth">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">隐藏后，个人中心的任务海报不显示</div>
          </div>
        </div>
        <div class="config-item">
          <h5>名称自定义</h5>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-30 font-w">商品</label>
            </div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">分销赚</label>
              <el-input v-model="enterpriseConfig.commissionAlias" style="width: 250px;" placeholder="最多3个字"
                maxlength="3" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后首页、自定义页、分类页、商品详情页的分销赚文字对应变化</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-30 font-w">个人中心_顾客</label>
            </div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">我的分销</label>
              <el-input v-model="enterpriseConfig.myCommissionAlias" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后1."我的分销"按钮名称 2.我的分销页小程序"标题栏名称"对应变化</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-30 font-w">个人中心_店主</label>
            </div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">顾客分销</label>
              <el-input v-model="enterpriseConfig.customerShareAlias" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后1."顾客分销"按钮名称 2.顾客分销页小程序"标题栏名称"对应变化</div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">分销商</label>
              <el-input v-model="enterpriseConfig.memberShareAlias" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后所有"分销商"文字对应变化</div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">分销订单</label>
              <el-input v-model="enterpriseConfig.projectOrderAlias" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后店主个人中心"分销订单"文字对应变化</div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">分销商品</label>
              <el-input v-model="enterpriseConfig.projectGoodsAlias" style="width: 250px;" placeholder="最多4个字"
                maxlength="4" />
            </div>
            <div class="config-tip font-12 font-color-9">设置后收入明细的"分销商品"文字对应变化</div>
          </div>
        </div>
        <div class="config-item">
          <h5>自营商品相关</h5>
          <div>
            <div class="v-align-c">
              <label class="config-label mar-r-15">自营商品显示</label>
              <el-radio-group v-model="enterpriseConfig.isSelfGoodsAuthority" :disabled="selfGoodsAuthorityFlag">
                <el-radio :label="1">显示</el-radio>
                <el-radio :label="0">隐藏</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">显示后无法再隐藏，店主在云店的卖家中心店铺管理中显示店铺设置、广告图、自营商品、自营分类等管理。
            </div>
          </div>
          <!-- 暂时隐藏 -->
          <!--<div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">自营商品抽点</label>
              <el-input style="width: 250px;" placeholder="请输入抽点比例">
                <template slot="append">%</template>
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置后在小程序中每笔成交的自营商品订单根据上方设置比例进行抽佣，填空或填0则不抽点。</div>
          </div>-->
        </div>
        <div class="config-item">
          <h5>自提订单提醒时间</h5>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">到店自提/社区团购订单</label>
              <el-input v-model="enterpriseConfig.noticeWaittingDeliveryIntervalTime" style="width: 250px;"
                maxlength="3"
                @keyup.native="enterpriseConfig.noticeWaittingDeliveryIntervalTime = checkInputPositiveNum(enterpriseConfig.noticeWaittingDeliveryIntervalTime)">
                <template slot="append">分钟</template>
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置待提货的提醒时间间隔，默认为3小时</div>
          </div>
        </div>
      </div>
      <!-- 批发小程序设置 -->
      <div class="scroll-item" id="wholesale-set" v-if="topNavBar['wholesale-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">批发小程序设置</div>
        </div>
        <div class="config-item">
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">强制完善主体认证</label>
              <el-radio-group v-model="enterpriseConfig.isOpenWholesaleCompulsoryPerfectionInfo">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，用户在批发小程序中申请批发商时必须先完善主体才能申请批发权限</div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">自动开通批发权限</label>
              <el-radio-group v-model="enterpriseConfig.isMemberWholesaleAuthority">
                <el-radio label="1">开启</el-radio>
                <el-radio label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">开启后，用户在成为本企业的微客后自动获得批发权限，关闭后则需手动设置批发权限</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">申请批发权限</label>
              <el-radio-group v-model="enterpriseConfig.isApplyWholesaleAuthority">
                <el-radio label="1">开启</el-radio>
                <el-radio label="0">关闭</el-radio>
              </el-radio-group>
            </div>
            <div class="config-tip font-12 font-color-9">关闭后用户则无法在小程序端申请批发权限</div>
          </div>
          <div v-if="enterpriseConfig.wholesaleOfflinePay == 1">
            <div class="mar-t-40">
              <div class="flex wholesale-pay-info">
                <label class="config-label mar-r-15">线下收款账户信息</label>
                <el-upload list-type="picture-card" ref="wholesaleCollectionImageRef" action="/api/common/uploadFiles"
                  accept="image/jpeg,image/gif,image/png,image/bmp" name="files" :data="token" :show-file-list="false"
                  :limit="1" v-loading="shareFileLoading" :on-success="handleUploadWholesaleOfflinePayImageUrlSuccess"
                  :before-upload="beforeWholesaleOfflinePayImageUrlUpload" style="width: 150px height:150px;">

                  <img v-if="enterpriseConfig.wholesaleCollectionImage"
                    :src="enterpriseConfig.wholesaleCollectionImage+ '?imageView2/1/w/200/h/200/q/100'"
                    style="width: 150px;height: 150px">

                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
                <div class="close-icon width-36 height-36 flex flex-center cursor-p"
                  @click="closeWholesaleCollectionImage()">
                  <svg-icon v-if="enterpriseConfig.wholesaleCollectionImage" icon-class="close"
                    class="icon font-16 noraml-hide active" />
                </div>
              </div>
              <div class="config-tip font-12 font-color-9">不上传则前端仅显示对公账户信息</div>
            </div>
            <div class="mar-t-40">
              <div class="v-align-c">
                <label class="config-label mar-r-15">支付方式</label>
                <el-switch v-model="wholesaleWechatStatusFlag" active-color="#13ce66" inactive-color="#ff4949"
                  active-text="微信支付"></el-switch>
              </div>
              <div class="v-align-c" style="margin-top: 10px;">
                <label class="config-label mar-r-15"></label>
                <el-switch v-model="wholesaleOfflineStatusFlag" active-color="#13ce66" inactive-color="#ff4949"
                  active-text="线下支付">
                </el-switch>
              </div>
              <div class="config-tip font-12 font-color-9">不开启则前端的收银台页将隐藏相应支付选项</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 对接参数 -->
      <div class="scroll-item" id="parameter-set" v-if="topNavBar['parameter-set'].showFlag">
        <div class="scroll-title-row">
          <div class="scroll-title">对接参数</div>
        </div>
        <div class="config-item">
          <h5>对外开放</h5>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">AppKey</label>
              <el-input v-model="enterpriseConfig.appKey" style="width: 250px;" :disabled="true">
              </el-input>
              <el-button type="text" class="mar-l-20" @click="handleClipboard(enterpriseConfig.appKey, $event)">复制
              </el-button>
            </div>
            <div class="config-tip font-12 font-color-9">与系统进行对接时，调用接口所使用的企业唯一ApppKey</div>
          </div>
          <div class="mar-t-40">
            <div class="v-align-c">
              <label class="config-label mar-r-15">AppSecret</label>
              <el-input v-model="enterpriseConfig.appSecret" style="width: 250px;" :disabled="true">
              </el-input>
              <el-button type="text" class="mar-l-20" @click="createAppSecret">重新生成</el-button>
              <el-button type="text" class="mar-l-20" @click="handleClipboard(enterpriseConfig.appKey, $event)">复制
              </el-button>
            </div>
            <div class="config-tip font-12 font-color-9">与系统进行对接时，生成token所使用的AppSecret</div>
          </div>
        </div>
        <div class="config-item">
          <h5>腾讯地图</h5>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">AppKey</label>
              <el-input v-model="enterpriseConfig.tencentAppKey" style="width: 250px;">
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">设置正确之后才能正常调用腾讯地图相关功能</div>
          </div>
        </div>
        <div class="config-item">
          <h5>跨境对接</h5>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">电商平台名称</label>
              <el-input v-model="enterpriseConfig.electricBusinessPlatformName" style="width: 250px;">
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">在海关备案的电商平台名称</div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">电商平台代码</label>
              <el-input v-model="enterpriseConfig.electricBusinessPlatformCode" style="width: 250px;">
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">在海关备案的电商平台编码</div>
          </div>
          <div class="mar-t-25">
            <div class="v-align-c">
              <label class="config-label mar-r-15">对接清关系统用户名</label>
              <el-input v-model="enterpriseConfig.crossBorderAllianceSystemUserName" style="width: 250px;">
              </el-input>
            </div>
            <div class="config-tip font-12 font-color-9">有第三方系统提供</div>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom-bar">
      <el-button type="primary" @click="saveEnterpriseConfig" :disabled="disabledSave">保存</el-button>
    </div>
  </div>
</template>

<script>
  import clipboard from '@/utils/clipboard'
  import {
    createAppSecret,
    getByEnterpriseId,
    saveEnterpriseConfig
  } from '@/api/user/enterprise'
  import {
    getDictByGroupName
  } from '@/api/common/common'
  import {
    getToken
  } from '@/utils/auth'
  import {
    getTaxList
  } from '@/api/warehouse/warehouseTaxItems'
  import {
    listAttribute,
    getAttribute
  } from '@/api/custom/customAttribute'
  import {
    listWarehouseInfo
  } from '@/api/warehouse/warehouseInfo'

  export default {
    data() {
      return {
        dict: {
          patternCommissionType: {},
          recruiterCommissionType: {}
        },
        fileLoading: false,
        bannerFileLoading: false,
        enableAfterSaleWarehouse: false,
        enableAfterSaleWarehouseCheckbox: true,
        enterpriseAudit: false,
        shareFileLoading: false,
        wholesaleWechatStatusFlag: false,
        wholesaleOfflineStatusFlag: false,
        enterpriseConfig: {
          // 店播管理 0 = 关闭 1 = 开启
          liveAuthority: 0,
          isShopAuditAuto: false,
          isSelfGoodsAuthority: 0,
          isLivePlaybackType: 0,
          isTaskPosterAuth: 0,
          isDistributionType: false,
          isMemberWholesaleAuthority: '0',
          isApplyWholesaleAuthority: '1',
          isLiveShowType: 0,
          customerServiceType: '1',
          isShopAutoApprove: 0,
          isShopBannerShow: 1,
          commissionCalculationType: '',
          anchorAutoApprove: 0,
          isShowAnchorOnePartnerCommission: 0,
          settlementRuleAuth: '0',
          categorySeparate: '0',
          wholesaleCategoryAlias: '0',
          taxItemsId: '',
          warehouseDeliverFlag: 0,
          ignoreAreaFlag: 0,
          closeWarehouseAudit: 1,
          commissionAlias: '',
          myCommissionAlias: '',
          customerShareAlias: '',
          memberShareAlias: '',
          warehouseAuthority: 1,
          projectOrderAlias: '',
          projectGoodsAlias: '',
          memberTitle: '',
          autoMemberAttrId: '',
          autoMemberAttrValue: '',
          isAutoCommander: 0,
          isCommanderBannerShow: 1,
          commanderBannerUrl: '',
          isOpenWholesaleCompulsoryPerfectionInfo: 0,
          isOpenAnchorCompulsoryPerfectionInfo: 0,
          electricBusinessPlatformName: '',
          electricBusinessPlatformCode: '',
          crossBorderAllianceSystemUserName: ''
        },
        defaultConfig: {
          enterpriseId: this.getEnterpriseId(),
          patternCommissionType: '1',
          recruiterCommissionType: '1',
          levelOnePartnerAliasName: '',
          levelTwoPartnerAliasName: '',
          livePlaybackType: 0,
          taskPosterAuth: 0,
          distributionType: 0,
          isShopAuditAuto: false,
          isSelfGoodsAuthority: 0
        },
        activeName: '0',
        disabledSave: false,
        selfGoodsAuthorityFlag: false,
        predefineColors: [],
        active: '1F',
        activeOther: '',
        scroll: 0,
        divisions: [],
        radio: 1,
        topNavBar: {
          'account-set': {
            name: '账期设置',
            target: 'account-set',
            showFlag: true
          },
          'goods-set': {
            name: '商品设置',
            target: 'goods-set',
            showFlag: true
          },
          'warehouse-set': {
            name: '进销存设置',
            target: 'warehouse-set',
            showFlag: true
          },
          'partner-set': {
            name: '合伙人设置',
            target: 'partner-set',
            showFlag: true
          },
          'recruiter-set': {
            name: '招募员设置',
            target: 'recruiter-set',
            showFlag: true
          },
          'anchor-set': {
            name: '主播设置',
            target: 'anchor-set',
            showFlag: true
          },
          'cloudshop-set': {
            name: '云店小程序设置',
            target: 'cloudshop-set',
            showFlag: true
          },
          'wholesale-set': {
            name: '批发小程序设置',
            target: 'wholesale-set',
            showFlag: true
          },
          'parameter-set': {
            name: '对接参数',
            target: 'parameter-set',
            showFlag: true
          }
        },
        selectedNavKey: 'account-set',
        // 启用仓库发货
        warehouseDeliverChecked: false,
        // 是否忽略就近原则
        ignoreAreaChecked: false,
        // 出入库审核
        warehouseAuditChecked: true,
        // 税目列表
        taxList: [],
        attributeList: [],
        attr: {},
        optionList: [],
        attrValue: '',
        afterSaleWarehouseList: [],
        // 合伙人申请默认审核标识
        partnerDefaultExamineFlag: false,
        // 招募员申请默认审核标识
        recruiterDefaultExamineFlag: false
      }
    },
    // 初始化页面
    created() {
      this.token = {
        accessToken: getToken()
      }
      this.initDict()
      this.initDataInfo()
      // 获取税目信息
      this.getTaxList()
      this.listAttribute()
      // 获取初始化的颜色值 全局设置
      this.predefineColors = this.$store.state.globalData.predefineColors
    },
    mounted() {
      const queryParams = this.getCurrentPage().query
      if (queryParams.active) {
        this.goTarget(queryParams.active)
      }
      const that = this
      window.addEventListener('mousewheel', function() {
        const scroll = document.documentElement.scrollTop || document.body.scrollTop
        for (var key in that.topNavBar) {
          if (that.topNavBar[key].showFlag) {
            if (that.topNavBar[key]['top'] - scroll < 185) {
              that.selectedNavKey = key
            }
          }
        }
      })
    },
    methods: {
      // 目标区域滚动
      goTarget(id) {
        document.querySelector('#' + id).scrollIntoView({
          behavior: 'smooth',
          block: 'center'
        })
        this.selectedNavKey = id
      },
      // 0-100数字校验
      checkNum(value) {
        const reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
        if (!this.$utils.isNumber(value) || parseFloat(value) < 0 || parseFloat(value) > 100 || !reg.test(value)) {
          return 0
        } else {
          return value
        }
      },
      handleClipboard(order, event) {
        const text = order
        clipboard(text, event)
      },
      initDataInfo() {
        this.selfGoodsAuthorityFlag = false
        getByEnterpriseId(this.getEnterpriseId()).then(response => {
          if (response.isError) return
          this.enterpriseConfig = !response.data ? {
            ...this.defaultConfig
          } : response.data
          this.$set(this.enterpriseConfig, 'isSelfGoodsAuthority', this.enterpriseConfig
            .selfGoodsAuthority)
          if (this.enterpriseConfig.selfGoodsAuthority === 1) {
            this.selfGoodsAuthorityFlag = true
          }
          this.$set(this.enterpriseConfig, 'isLivePlaybackType', this.enterpriseConfig.livePlaybackType)
          this.$set(this.enterpriseConfig, 'isTaskPosterAuth', this.enterpriseConfig.taskPosterAuth)
          this.$set(this.enterpriseConfig, 'isDistributionType', this.enterpriseConfig
            .distributionType === 1)
          this.$set(this.enterpriseConfig, 'isMemberWholesaleAuthority', this.enterpriseConfig
            .memberWholesaleAuthority.toString())
          this.$set(this.enterpriseConfig, 'isApplyWholesaleAuthority', this.enterpriseConfig
            .applyWholesaleAuthority.toString())
          this.$set(this.enterpriseConfig, 'isLiveShowType', this.enterpriseConfig.liveShowType)
          this.$set(this.enterpriseConfig, 'customerServiceType', this.enterpriseConfig
            .customerServiceType || '')
          this.$set(this.enterpriseConfig, 'isShopAutoApprove', this.enterpriseConfig.shopAutoApprove)
          this.$set(this.enterpriseConfig, 'isShopBannerShow', this.enterpriseConfig.shopBannerShow)

          this.$set(this.enterpriseConfig, 'isCommanderAutoApprove', this.enterpriseConfig.commanderAutoApprove)
          this.$set(this.enterpriseConfig, 'isCommanderBannerShow', this.enterpriseConfig.commanderBannerShow)

          this.$set(this.enterpriseConfig, 'memberTitle', this.enterpriseConfig.memberTitle || '')
          this.$set(this.enterpriseConfig, 'autoMemberAttrId', this.enterpriseConfig.autoMemberAttrId ||
            '')
          this.$set(this.enterpriseConfig, 'autoMemberAttrValue', this.enterpriseConfig
            .autoMemberAttrValue || '')
          this.enterpriseConfig.patternCommissionType = this.enterpriseConfig.patternCommissionType
            .toString()
          this.enterpriseConfig.recruiterCommissionType = this.enterpriseConfig.recruiterCommissionType
            .toString()
          this.enterpriseConfig.settlementRuleAuth = this.enterpriseConfig.settlementRuleAuth.toString()
          this.$set(this.enterpriseConfig, 'anchorAutoApprove', this.enterpriseConfig.anchorAutoApprove || 0)
          this.$set(this.enterpriseConfig, 'isShowAnchorOnePartnerCommission', this.enterpriseConfig
            .isShowAnchorOnePartnerCommission || 0)
          this.enterpriseConfig.commissionCalculationType = this.enterpriseConfig.commissionCalculationType
            .toString()
          this.warehouseDeliverChecked = this.enterpriseConfig.warehouseDeliverFlag === 1
          this.ignoreAreaChecked = this.enterpriseConfig.ignoreAreaFlag === 1
          this.warehouseAuditChecked = this.enterpriseConfig.closeWarehouseAudit === 1
          this.enableAfterSaleWarehouse = this.enterpriseConfig.enableAfterSaleWarehouse === 1
          this.enterpriseAudit = this.enterpriseConfig.enterpriseAudit === 1
          this.enableAfterSaleWarehouseCheckbox = !this.enterpriseAudit
          if (this.enterpriseConfig.warehouseAuthority === 0) {
            this.topNavBar['warehouse-set'].showFlag = false
          }
          if (this.enterpriseConfig.wholesaleAuthority === 0) {
            this.topNavBar['wholesale-set'].showFlag = false
            this.topNavBar['goods-set'].showFlag = false
          }
          if (this.enterpriseConfig.isOpenWholesaleWechat === 1) {
            this.wholesaleWechatStatusFlag = true
          } else {
            this.wholesaleWechatStatusFlag = false
          }
          if (this.enterpriseConfig.isOpenWholesaleOffline === 1) {
            this.wholesaleOfflineStatusFlag = true
          } else {
            this.wholesaleOfflineStatusFlag = false
          }
          this.$nextTick(function() {
            for (var key in this.topNavBar) {
              if (this.topNavBar[key].showFlag) {
                const dom = document.getElementById(key)
                this.$set(this.topNavBar[key], 'top', dom.offsetTop)
              }
            }
          })
          if (this.enterpriseConfig.autoMemberAttrId) {
            this.getAttribute(this.enterpriseConfig.autoMemberAttrId)
          }
          // 合伙人申请默认审核开关
          if (this.enterpriseConfig.partnerDefaultExamineFlag === 1) {
            this.partnerDefaultExamineFlag = true
          } else {
            this.partnerDefaultExamineFlag = false
          }
          // 招募员申请默认审核开关
          if (this.enterpriseConfig.recruiterDefaultExamineFlag === 1) {
            this.recruiterDefaultExamineFlag = true
          } else {
            this.recruiterDefaultExamineFlag = false
          }
        })
      },
      createAppSecret() {
        createAppSecret(this.getEnterpriseId()).then(response => {
          if (response.isError) return
          this.enterpriseConfig.appSecret = response.data
        })
      },
      saveEnterpriseConfig() {
        if (this.enterpriseConfig.updateOrderReceived * 1 < 1) {
          this.$message.error('订单自动确认收货时间最短为1天')
          return
        }
        this.disabledSave = true
        this.enterpriseConfig.selfGoodsAuthority = this.enterpriseConfig.isSelfGoodsAuthority
        this.enterpriseConfig.livePlaybackType = this.enterpriseConfig.isLivePlaybackType
        this.enterpriseConfig.taskPosterAuth = this.enterpriseConfig.isTaskPosterAuth
        this.enterpriseConfig.distributionType = this.enterpriseConfig.isDistributionType ? 1 : 0
        this.enterpriseConfig.memberWholesaleAuthority = this.enterpriseConfig.isMemberWholesaleAuthority
        this.enterpriseConfig.applyWholesaleAuthority = this.enterpriseConfig.isApplyWholesaleAuthority
        this.enterpriseConfig.liveShowType = this.enterpriseConfig.isLiveShowType
        this.enterpriseConfig.shopAutoApprove = this.enterpriseConfig.isShopAutoApprove
        this.enterpriseConfig.shopBannerShow = this.enterpriseConfig.isShopBannerShow
        this.enterpriseConfig.commanderAutoApprove = this.enterpriseConfig.isCommanderAutoApprove
        this.enterpriseConfig.commanderBannerShow = this.enterpriseConfig.isCommanderBannerShow
        this.enterpriseConfig.enterpriseId = this.getEnterpriseId()
        // 进销存设置保存时赋值
        this.enterpriseConfig.warehouseDeliverFlag = this.warehouseDeliverChecked ? 1 : 0
        this.enterpriseConfig.ignoreAreaFlag = this.ignoreAreaChecked ? 1 : 0
        this.enterpriseConfig.closeWarehouseAudit = this.warehouseAuditChecked ? 1 : 0
        this.enterpriseConfig.isOpenWholesaleWechat = this.wholesaleWechatStatusFlag ? '1' : '0'
        this.enterpriseConfig.isOpenWholesaleOffline = this.wholesaleOfflineStatusFlag ? '1' : '0'
        this.enterpriseConfig.enterpriseAudit = this.enterpriseAudit ? '1' : '0'
        this.enterpriseConfig.enableAfterSaleWarehouse = this.enableAfterSaleWarehouse ? '1' : '0'
        if (this.enterpriseConfig.wholesaleOfflinePay === 1) {
          if (this.enterpriseConfig.isOpenWholesaleWechat === '0' && this.enterpriseConfig.isOpenWholesaleOffline ===
            '0') {
            this.disabledSave = false
            this.$message.error('批发小程序：至少开启一种支付方式')
            return
          }
        }
        // 合伙人申请审核默认开关
        this.enterpriseConfig.partnerDefaultExamineFlag = this.partnerDefaultExamineFlag ? '1' : '0'
        // 招募员申请审核默认开关
        this.enterpriseConfig.recruiterDefaultExamineFlag = this.recruiterDefaultExamineFlag ? '1' : '0'

        saveEnterpriseConfig(this.enterpriseConfig).then(response => {
          this.disabledSave = false
          if (response.isError) return
          this.$message({
            message: '成功',
            type: 'success'
          })
        })
      },
      initDict() {
        getDictByGroupName('EnterpriseConfigDTO').then(response => {
          if (response.isError) return
          this.dict = response.data
        })
        // 获取售后仓库列表
        const data = {
          enterpriseId: this.getEnterpriseId(),
          supplierId: this.getSupplierId(),
          warehouseSource: this.getSupplierId() ? 2 : 1,
          status: 1,
          // 售后仓
          afterSaleWarehouseFlag: 2
        }
        listWarehouseInfo(data).then((response) => {
          this.afterSaleWarehouseList = response.data
        })
      },
      beforeImageUrlUpload(file) {
        const isJPG = file.type === 'image/jpeg'
        const isGIF = file.type === 'image/gif'
        const isPNG = file.type === 'image/png'
        const isBMP = file.type === 'image/bmp'
        if (!isJPG && !isGIF && !isPNG && !isBMP) {
          this.$message({
            type: 'error',
            message: '上传图片必须是JPG/GIF/PNG/BMP 格式!'
          })
        } else {
          this.fileLoading = true
        }
        return (isJPG || isBMP || isGIF || isPNG)
      },
      handleUploadImageUrlSuccess(res, file) {
        this.fileLoading = false
        if (res.code === 101) {
          this.enterpriseConfig.logoUrl = res.data[0]
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
          return false
        }
      },
      beforeBannerUpload(file) {
        const isJPG = file.type === 'image/jpeg'
        const isGIF = file.type === 'image/gif'
        const isPNG = file.type === 'image/png'
        const isBMP = file.type === 'image/bmp'
        if (!isJPG && !isGIF && !isPNG && !isBMP) {
          this.$message({
            type: 'error',
            message: '上传图片必须是JPG/GIF/PNG/BMP 格式!'
          })
        } else {
          this.bannerFileLoading = true
        }
        return (isJPG || isBMP || isGIF || isPNG)
      },
      handleUploadBannerSuccess(res, file) {
        this.bannerFileLoading = false
        if (res.code === 101) {
          this.enterpriseConfig.shopBannerUrl = res.data[0]
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
          return false
        }
      },
      handleUploadCommanderBannerSuccess(res, file) {
        this.bannerFileLoading = false
        if (res.code === 101) {
          this.enterpriseConfig.commanderBannerUrl = res.data[0]
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
          return false
        }
      },
      beforeWholesaleOfflinePayImageUrlUpload(file) {
        const isJPG = file.type === 'image/jpeg'
        const isGIF = file.type === 'image/gif'
        const isPNG = file.type === 'image/png'
        const isBMP = file.type === 'image/bmp'

        if (!isJPG && !isGIF && !isPNG && !isBMP) {
          this.$message.error('上传图片必须是JPG/GIF/PNG/BMP 格式!')
        }
        this.shareFileLoading = true
        return (isJPG || isBMP || isGIF || isPNG)
      },
      handleUploadWholesaleOfflinePayImageUrlSuccess(res, file) {
        this.shareFileLoading = false
        if (res.code === 101) {
          const imageUrl = res.data[0]
          this.enterpriseConfig.wholesaleCollectionImage = imageUrl
          this.$refs.wholesaleCollectionImageRef.clearFiles()
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
          return false
        }
      },
      colorChange(obj, key, defaultColor, e) {
        // 颜色值变化
        if (!e) {
          obj[key] = defaultColor
        }
      },
      activecolorChange(obj, key, defaultColor, e) {
        // 调色板中值变化
        if (!e) {
          obj[key] = defaultColor
        }
      },
      iptColorChange(obj, key, defaultColor, e) {
        // 颜色输入框触发事件
        if (this.$utils.isHexColor(e)) {
          obj[key] = e
        } else {
          obj[key] = defaultColor
        }
      },
      resetColor(obj, key, defaultColor) {
        // 重置颜色按钮触发事件
        obj[key] = defaultColor
      },
      // 自定义属性
      changeAttribute(attributeId) {
        this.enterpriseConfig.autoMemberAttrValue = ''
        if (!attributeId) {
          return
        }
        this.getAttribute(attributeId)
      },
      getAttribute(attributeId) {
        getAttribute(attributeId).then((response) => {
          if (response.isError) return
          this.attr = response.data
          this.optionList = this.attr.optionList
        })
      },
      listAttribute() {
        listAttribute({
          enterpriseId: this.getEnterpriseId(),
          moduleCode: 1001
        }).then(response => {
          if (response.isError) return
          this.attributeList = response.data
        })
      },
      // 获取用户的税目列表
      getTaxList() {
        getTaxList(this.getEnterpriseId()).then(response => {
          if (response.isError) return
          this.taxList = response.data
        })
      },
      changeDefaultAfterSaleWarehouse() {
        if (this.enterpriseConfig.defaultAfterSaleWarehouseId) {
          this.enableAfterSaleWarehouse = true
        } else {
          this.enableAfterSaleWarehouse = false
        }
      },
      changeEnableAfterSaleWarehouse() {
        if (!this.enableAfterSaleWarehouse) {
          this.enterpriseConfig.defaultAfterSaleWarehouseId = ''
        }
      },
      closeWholesaleCollectionImage() {
        this.enterpriseConfig.wholesaleCollectionImage = undefined
      },
      changeEnterpriseAudit() {
        this.enableAfterSaleWarehouseCheckbox = !this.enterpriseAudit
        if (!this.enterpriseAudit) {
          this.enableAfterSaleWarehouseCheckbox = !this.enterpriseAudit
          this.enterpriseConfig.defaultAfterSaleWarehouseId = ''
          this.enableAfterSaleWarehouse = false
        } else {
          this.enableAfterSaleWarehouse = true
        }
      }
    }
  }
</script>

<style lang="less" scoped>
  .bgc-default {
    padding-bottom: 70px;
  }

  .top-nav {
    position: sticky;
    top: 50px;
    left: 0;
    width: 100%;
    height: 60px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 999;
    box-shadow: 0 2px 6px #eee;

    .nav-item {
      cursor: pointer;
    }

    .nav-active {
      position: relative;
      color: #409eff;

      &::after {
        content: '';
        position: absolute;
        bottom: -20px;
        left: -15px;
        width: calc(100% + 30px);
        height: 2px;
        background-color: #409eff;
      }
    }
  }

  .scroll-item {
    .scroll-title-row {
      background-color: #f7f8fa;
      padding-left: 20px;

      .scroll-title {
        height: 50px;
        line-height: 50px;
        padding-left: 10px;
        position: relative;

        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 25px;
          width: 3px;
          height: 15px;
          background-color: #006aff;
          transform: translateY(-50%);
        }
      }
    }

    .config-item {
      margin-bottom: 40px;

      .mar-t-40 {
        margin-top: 40px;
      }

      h5 {
        width: 150px;
        text-align: right;
        font-size: 14px;
        margin: 26px 0 6px;
      }

      .config-label {
        font-size: 14px;
        font-weight: unset;
        width: 275px;
        text-align: right;
      }

      .config-label-2 {
        font-size: 14px;
        font-weight: unset;
        width: 100px;
        text-align: right;
      }

      .config-tip {
        margin-left: 290px;
      }

      .config-tip-2 {
        margin-left: 405px;
      }

      /deep/ .el-upload--picture-card {
        width: 150px;
        height: 50px;
        box-sizing: unset;
        line-height: 60px;

        img {
          border-radius: 6px;
        }
      }

      /deep/ .wholesale-pay-info .el-upload--picture-card {
        width: 150px;
        height: 150px;
        box-sizing: unset;
        line-height: 162px;

        img {
          border-radius: 6px;
        }
      }
    }
  }

  .bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 999;
    box-shadow: 0 -2px 8px #eeeeee;

    .el-button {
      width: 100px;
      height: 40px;
      line-height: 40px;
      padding: 0;
    }
  }
</style>
